programming4us
           
 
 
Windows Server

Windows Server 2008 Server Core : Creating LNK Files

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/30/2010 9:41:34 AM
Up until now, you may have taken LNK (link) files for granted in Windows because they're exceptionally easy to create. Unfortunately, without a GUI in Server Core, it's become significantly harder to create LNK files. You'll find a ton of references to an elusive Shortcut utility for Windows online, but you won't find the actual executable on your hard drive, which may leave you puzzling for a long time. It's possible to create LNK files using scripts. Listing 1 shows a script that places a LNK file on your Desktop for Notepad. Now you can double-click this LNK file and open a copy of Notepad (menu not required).

Server Core may not display links on the Desktop. In this case, you can still place links in a common folder, such as %USERPROFILE%, which points to your user folder. You can still type the LNK filename and press Enter to use the link file from the command line. In short, LNK files are still useful, even if you can't see their physical manifestation in the form of an icon.


Example 1. Creating a New LNK File
' Create the shell object.
Set WshShell = WScript.CreateObject("WScript.Shell")

' Define the location of the LNK file.
LinkFilename = WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
LinkFilename = LinkFilename + "\Desktop\Notepad.LNK"

' Create the LNK file object.
Set LNKFile = WshShell.CreateShortcut(LinkFilename)

' Set the LNK file contents.
LNKFile.TargetPath = "%SYSTEMROOT%\System32\Notepad.EXE"
LNKFile.Arguments = ""
LNKFile.Description = "Open Notepad"
LNKFile.HotKey = ""
LNKFile.IconLocation = "%SYSTEMROOT%\System32\Notepad.EXE, 1"
LNKFile.WindowStyle = "1"
LNKFile.WorkingDirectory = "C:\"

' Save the LNK file to disk.
LNKFile.Save

The code begins by creating a Windows Script shell. This shell provides access to features such as environment strings and the function for creating a shortcut. The next step creates a location name based on the user's profile—the \Users\UserName folder for the user. You may use any of the environment variables that Windows supports to obtain information for your scripts. It then adds the actual LNK file location to the path.

Now that the code has a path to use for creating the LNK file, it uses the CreateShortcut() function to create it. At this point, the script sets the various LNK file contents. Any field you can change in a LNK file, you can also change using a script. Finally, the script saves the results to the hard drive. It's essential to perform this final step or LNK file won't work. Simply type the LNK filename and press Enter to execute it at the command line. For example, in this case you would type Notepad.LNK and press Enter at the command line to start a copy of Notepad.

You can find a downloadable version of the Shortcut command at http://www.optimumx.com/download/. The Shortcut command provides the means to create a LNK file without resorting to using a script. In addition, you can use it to create an INI file that contains all of the LNK file configuration information. The ReadMe.TXT file that comes with the Shortcut command tells you about all of the command line parameters you need to use it.

Other -----------------
- Configuring BitLocker Drive Encryption on a Windows Server 2008 R2 Branch Office Domain Controller (part 4)
- Configuring BitLocker Drive Encryption on a Windows Server 2008 R2 Branch Office Domain Controller (part 3) - Enabling BitLocker Drive Encryption when TPM Is Not Available
- Configuring BitLocker Drive Encryption on a Windows Server 2008 R2 Branch Office Domain Controller (part 2) - Enabling BitLocker Drive Encryption with TPM
- Configuring BitLocker Drive Encryption on a Windows Server 2008 R2 Branch Office Domain Controller (part 1)
- Windows Server 2008: Understanding BitLocker Drive Encryption
- Windows Server 2008: Installing a Read-Only Domain Controller (part 4) - Performing a Staged RODC Installation
- Windows Server 2008: Installing a Read-Only Domain Controller (part 3)
- Windows Server 2008: Installing a Read-Only Domain Controller (part 2)
- Windows Server 2008: Installing a Read-Only Domain Controller (part 1)
- Windows Server 2008: Understanding Read-Only Domain Controllers (part 2) - Understanding When to Leverage RODCs
- Windows Server 2008: Understanding Read-Only Domain Controllers (part 1)
- Windows Server 2008 : Understanding the Windows AIK (part 5) - Understanding Sysprep
- Windows Server 2008 : Understanding the Windows AIK (part 4) - Understanding ImageX and the .wim File Format
- Windows Server 2008 : Understanding the Windows AIK (part 3) - Understanding Windows PE
- Windows Server 2008 : Understanding the Windows AIK (part 2) - Understanding Windows SIM and Answer Files
- Windows Server 2008 : Understanding the Windows AIK (part 1)
- Windows Server 2008 : Configuring Windows Media Services (part 14) - Configuring Proxy Settings
- Windows Server 2008 : Configuring Windows Media Services (part 13) - Configuring Caching Settings
- Windows Server 2008 : Configuring Windows Media Services (part 12) - Enabling Cache/Proxy
- Windows Server 2008 : Configuring Windows Media Services (part 11) - Configuring Security for Windows Media Services
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us